package Dispatcher;

/**
 * Asks elevator for its status every 500 ms
 * 
 * @author Varun Maryada, Sanat Dixit, Steve Tannahill
 * 
 */
public class UpdateThread extends Thread {
	private GroupDispatcher gd;

	private static final int REQUESTUPDATE = 3;
	
	public UpdateThread(GroupDispatcher gd) {
		this.gd = gd;
	}

	@Override
	public void run() {
		while (true) {
			try {
				Thread.sleep(500);
				for (int i : gd.elevators.keySet()) {
					if (gd.elevators.get(i) != null) {
						gd.elevators.get(i).println(REQUESTUPDATE + "\n");
					}
				}
			} catch (InterruptedException e) {
			}
		}
	}
}